package com.rms.utils.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;


@WebFilter(filterName="CharsetEncodingFilter",urlPatterns="/*")
public class CharsetEncodingFilter implements Filter {

	private String encoding = "utf-8";
   
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		//设置请求编码
		request.setCharacterEncoding(encoding);
		//设置响应头
		response.setContentType("text/html;charset=utf-8");
		//放行
		chain.doFilter(request, response);
	}

	
}
